import IBattleEffect from "./IBattleEffect";
import { IEnvironment } from "../../env/IEnvironment";
import { IBattleAttacker } from "../../player/IBattleAttacker";
import { BattlePosFinder } from "./BattlePosFinder";
/**
 * 负责子弹，技能，效果的初始设置和行为实现
 */
export abstract class BattleEffectAction<T extends IBattleEffect, A extends IBattleAttacker, E extends IEnvironment> {

    protected target: T

    protected posFinder: BattlePosFinder<E> = null;

    setFinder(finder: BattlePosFinder<E>) {
        this.posFinder = finder;
    }

    setTarget(t: T) {
        this.target = t;
    }

    action(attacker: A, behiter: A, world: E) {
        this.addChild(attacker, behiter, world)
        this.setFlyType(attacker, behiter, world)
    }

    /**
     * 默认直接添加到世界中。
     * @param attacker 
     * @param behiter 
     * @param world 
     */
    protected addChild(attacker: A, behiter: A, world: E) {
        world.addChild(this.target.getNode())
    }


    protected abstract setFlyType(attacker: A, behiter: A, world?: E): void;

    updateLogic(dt: number) {

    }
}